package com.zmzncs.lmtc.module.shop.pojo.shop_goods;

import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.apache.commons.lang3.StringUtils;

import java.io.Serializable;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

/**
 * <p>
 * 商户-商品
 * </p>
 *
 * @author 高博文
 * @since 2021-05-20
 */
@Data
public class ShopGoodsVO implements Serializable {

    private static final long serialVersionUID=1L;

    @ApiModelProperty(value = "id")
    private Long id;

    @ApiModelProperty(value = "商户id")
    private Long shopId;

    @ApiModelProperty(value = "商品名称")
    private String goodsName;

    @ApiModelProperty(value = "商品文件URL")
    private List<String> fileUrl;

    @ApiModelProperty(value = "商品文件地址")
    List<String> fileList;

    @ApiModelProperty(value = "价格")
    private BigDecimal originalPrice;

    @ApiModelProperty(value = "销售价")
    private BigDecimal sellPrice;

    @ApiModelProperty(value = "库存")
    private Integer stock;

    @ApiModelProperty(value = "是否限购（0：否，1：是）")
    private String isLimitQuantity;

    @ApiModelProperty(value = "限购数量")
    private String limitQuantity;

    @ApiModelProperty(value = "有效期")
    private Date expireDate;

    @ApiModelProperty(value = "商品描述")
    private String description;

    @ApiModelProperty(value = "商家名称")
    private String shopName;

    public List<String> getFileUrl() {
        return fileUrl;
    }

    public void setFileUrl(List<String> fileUrl) {
        if(fileUrl!=null && fileUrl.size()>0){
            String[] files =  fileUrl.get(0).split(";");
            for(String fileStr : files){
                fileUrl.add(fileStr);
            }
            fileUrl.remove(0);
        }
        this.fileUrl = fileUrl;
    }
}
